<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageScope.request.contextPath}"/>  
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>   

<title>学生列表</title>

	<a href="${ctx}/students/add" btn btn-primary btn-lg active>添加</a>
	<hr />
	
	<form action="${ctx }/students/home" method="get">
		
		<input name="name" type="text" placeholder="请输入姓名" value="${param.name}" />  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		
		<select name="gender">
			<option value="">请选择</option>
			<c:forEach var="gender" items="${genders}">
				<option value="${gender}"  ${param.gender==gender?'selected':''}>${gender.text }</option>
			</c:forEach>
		</select>
		 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		 
		 <button type="submit">查询</button>
	
	</form>
	<br>
	<table>	
		<tr>	
			<th>序号</th>
			<th>姓名</th>
			<th>性别</th>
			<th>生日</th>
			<th>修改</th>
			<th>删除</th>
		</tr>		
		<c:forEach var="students" items="${pageable.elements}" varStatus="stat">
		<tr>
			<td>${stat.index +1}</td>
			<td>${students.name }</td>
			<td>${students.gender.text }</td>
			<td><fmt:formatDate value="${students.birthday }" pattern="yyyy-MM-dd"/> </td>
			<th><a href="${ctx }/students/update?id=${students.id }">修改</a></th>
			<th><a href="${ctx }/students/delete?id=${students.id }" onclick="confirm('确定要删除吗?')">删除</a></th>
		</tr>
		</c:forEach>
	</table>
	<div>
			
			<a href="${pageable.firstHref}">第一页</a>  		
			<a href="${pageable.nextHref }">下一页</a>
			<a href="${empty pageable.previousHref?'':pageable.previousHref }"> 上一页</a>
			<a href="${empty pageable.lastHref?'':pageable.lastHref }"> 最 后一页</a>  
			   共 ${pageable.total }条，${pageable.totalPage}页
	
	</div>
